<template>
  <div class="hote-detail">
    <home-header>
      <div slot="title" class="logoImg">{{ title }}</div>
    </home-header>
    <hote-list-main :hotelList="hotelList"></hote-list-main>
  </div>
</template>

<script>
import HomeHeader from "../header/Header";
import HoteListMain from "./components/MainPart";
import axios from "axios";
export default {
  name: "HoteDetailList",
  components: {
    HomeHeader,
    HoteListMain
  },
  data() {
    return {
      title: "",
      hotelList: null,
      hotelId: this.$route.params.id
    };
  },
  created() {
    // 请求旅馆数据
    this.getMerchantInfo();
    console.log("路由更新了", this.$route.params.id);
  },
  methods: {
    getMerchantInfo() {
      axios
        .get("/mock/merchant.json")
        .then(this.handleGetDataSucc)
        .catch(function(error) {
          console.log(error);
        });
    },
    handleGetDataSucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        data.forEach(item => {
          if (this.hotelId == item.id) {
            this.title = item.title;
            this.hotelList = item.subMenuContent;
          }
        });
      }
    }
  }
};
</script>
